/**
 * 多语言支持
 *
 * @author jinzhengze
 */
import {useStorage} from '@vueuse/core'

const language = useStorage(process.env?.VUE_APP_LANG ?? 'LANGUAGE', 'zh')

function translate(val) {
    if (typeof val === 'object') {
        const keys = Object.keys(val)
        if (!keys.length) return 'T_ERROR'
        return val[language.value] || val[keys[0]]
    }
    if (!val) return val
    let item = lang.find(obj => val === obj['zh'] || val === obj['en'] || val === obj['jp'])
    if (!item) return val
    return item[language.value] ? item[language.value] : val
}

// 默认翻译
const lang = [
    {"zh": "弹幕配置", "en": "Chat Config", "jp": "弾幕配置"},
    {"zh": "平台配置", "en": "Platform Config", "jp": "平台配置"},
    {"zh": "资源管理", "en": "Resource Manage", "jp": "リソース管理"},
    {"zh": "语言", "en": "Language", "jp": "言語"},

    {"zh": "操作", "en": "Operation", "jp": "操作"},
    {"zh": "开通", "en": "Activate", "jp": "開通"},
    {"zh": "常规", "en": "Routine", "jp": "標準"},
    {"zh": "配置名称", "en": "Config Name", "jp": "構成名"},
    {"zh": "直播平台", "en": "Platform", "jp": "ホーム"},
    {"zh": "房间号", "en": "Room ID", "jp": "ルームナンバー"},
    {"zh": "直播间房间号", "en": "Live Room ID", "jp": "ライブルーム番号"},
    {"zh": "显示欢迎", "en": "Display Welcome", "jp": "ようこそを表示"},
    {"zh": "显示弹幕", "en": "Display Danmu", "jp": "弾幕を表示"},
    {"zh": "显示超级弹幕", "en": "Display Super Chat", "jp": "スーパーチャット"},
    {"zh": "显示礼物", "en": "Display Gift", "jp": "プレゼントを表示"},
    {"zh": "屏蔽", "en": "Block", "jp": "しゃへい"},
    {"zh": "屏蔽关键词", "en": "Block Keywords", "jp": "マスクキーワード"},
    {"zh": "屏蔽用户", "en": "Block Users", "jp": "ユーザーのマスク"},
    {"zh": "暂无相关信息", "en": "No relevant information available at the moment", "jp": "関連情報はありません"},
    {"zh": "跳转直播姬", "en": "To Live Chat", "jp": "リアルタイムチャット"},
    {"zh": "拉取配置", "en": "Pull Config", "jp": "プル構成"},
    {"zh": "同步配置", "en": "Sync Config", "jp": "同期構成"},
    {"zh": "拉取", "en": "Pull", "jp": "プル"},
    {"zh": "同步", "en": "Sync", "jp": "同期"},
    {"zh": "开启滚动", "en": "Enable Scroll", "jp": "ロールオン"},
    {"zh": "屏蔽的内容", "en": "Blocked Content", "jp": "屏蔽内容"},
    {"zh": "关闭", "en": "Close", "jp": "オフ"},
    {"zh": "确认", "en": "Confirm", "jp": "確認"},
    {"zh": "删除", "en": "Delete", "jp": "削除"},
    {"zh": "新增", "en": "Add", "jp": "追加"},
    {"zh": "提交", "en": "Submit", "jp": "送信"},
    {"zh": "平台不存在", "en": "Platform does not exist", "jp": "プラットフォームが存在しません"},
    {"zh": "确认提交", "en": "Confirm", "jp": "コミットの確認"},
    {"zh": "屏蔽内容不能为空", "en": "Blocked content cannot be empty", "jp": "マスクを空にすることはできません"},
    {"zh": "已存在该屏蔽信息", "en": "The shielding information already exists", "jp": "マスク情報は既に存在します"},
    {"zh": "切换语言", "en": "Switch Lang", "jp": "言語の切り替え"},
    {"zh": "直播弹幕离线中", "en": "Live Chat Offline", "jp": "ライブ弾幕オフライン中"},
    {"zh": "在此输入内容", "en": "Enter content here", "jp": "ここに内容を入力"},
    {"zh": "数据异常，请刷新网页", "en": "Data exception, please refresh the webpage", "jp": "データ異常、Webページを更新してください"},
    {"zh": "没有更多了", "en": "There's no more", "jp": "これ以上ない"},
    {"zh": "新建资源", "en": "New Resource", "jp": "新規リソース"},
    {"zh": "自定义ID", "en": "Custom ID", "jp": "カスタムID"},
    {"zh": "不填写则使用文件MD5校验值", "en": "Default use the file MD 5 verification value", "jp": "デフォルトでは、ファイルMD 5を使用して値を検証します"},
    {"zh": "资源文件", "en": "Res File", "jp": "リソース"},
    {"zh": "点击选择或拖拽至此", "en": "Click to select or drag here", "jp": "クリックして選択またはドラッグしてください"},
    {"zh": "复制成功", "en": "Successfully Copied", "jp": "コピー成功"},
    {"zh": "仅支持PNG，JPG，GIF图片类型", "en": "Only PNG, JPG, GIF image types are supported", "jp": "PNG，JPG，GIFピクチャタイプのみ対応"},
    {"zh": "添加关键字", "en": "Add Keywords", "jp": "キーワードの追加"},
    {"zh": "添加用户", "en": "Add User", "jp": "ユーザーの追加"},
    {"zh": "上传资源", "en": "Upload Resources", "jp": "リソースのアップロード"},
    {"zh": "已配置", "en": "Already", "jp": "すでに"},
    {"zh": "未配置", "en": "Not", "jp": "いいえ"},
    {"zh": "配置未同步", "en": "Config not synchronized", "jp": "未同期の構成"},
    {"zh": "监听断开，请检查日志", "en": "Listening disconnected, please check logs", "jp": "リスニングフラクチャ、ログを確認してください"},
    {"zh": "弹幕滚动已暂停", "en": "Chat screen scrolling paused", "jp": "弾幕のスクロールが一時停止しました"},
    {"zh": "弹幕滚动已启动", "en": "Chat screen scrolling activated", "jp": "弾幕のスクロールが開始されました"},
    {"zh": "项目地址", "en": "Project Address", "jp": "プロジェクトアドレス"},
    {"zh": "前往项目仓库", "en": "Go to the project warehouse", "jp": "プロジェクトウェアハウスへの移動"},

    // SERVER MSG
    {"zh": "平台数据不存在", "en": "Platform data does not exist", "jp": "プラットフォームデータが存在しません"},
    {"zh": "配置名称不能为空", "en": "Configuration name cannot be empty", "jp": "構成名を空にすることはできません"},
    {"zh": "平台不能为空", "en": "Platform cannot be empty", "jp": "プラットフォームを空にすることはできません"},
    {"zh": "房间不能为空", "en": "Room cannot be empty", "jp": ""},
    {"zh": "配置新增失败", "en": "", "jp": "部屋を空にすることはできません"},
    {"zh": "配置对象ID不存在", "en": "Configuration object ID does not exist", "jp": "構成オブジェクトIDが存在しません"},
    {"zh": "配置对象数据为空", "en": "The configuration object data is empty", "jp": "構成オブジェクトデータがNULLです"},
    {"zh": "自定义ID已存在对应资源", "en": "The corresponding resource already exists for the custom ID", "jp": "カスタムIDにはすでに対応するリソースが存在します"},
    {"zh": "文件不存在", "en": "File does not exist", "jp": "ファイルが存在しません"},
    {
        "zh": "平台信息未配置，请根据要求配置相关信息",
        "en": "The platform information is not configured. Please configure the relevant information according to the requirements",
        "jp": "プラットフォーム情報は構成されていません。必要に応じて関連情報を構成してください"},
    {"zh": "获取平台房间信息失败", "en": "Failed to obtain platform room information", "jp": "プラットフォームルーム情報の取得に失敗しました"},

]

export default translate
